//技术咨询与导师解答
import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  ConsultationForm,
  ConsultationPageResult,
  ConsultationQuery,
} from "./types";

/**
 * 获取技术咨询分页数据
 *
 * @param queryParams
 */
export function getConsultationPage(
  queryParams: ConsultationQuery
): AxiosPromise<ConsultationPageResult> {
  return request({
    url: "/api/sys/consultation/page",
    method: "get",
    params: queryParams,
  });
}

/**
 * 获取技术咨询详情
 *
 * @param id
 */
export function getConsultationForm(
  id: string
): AxiosPromise<ConsultationForm> {
  console.log(id);

  return request({
    url: "/api/sys/consultation/getBy{id}?id=" + id,
    method: "get",
  });
}

/**
 * 添加技术咨询
 *
 * @param data
 */
export function addConsultation(data: ConsultationForm) {
  return request({
    url: "/api/sys/consultation/add",
    method: "post",
    data: {
      demand: data.demand,
      project_brief: data.project_brief,
      question: data.question,
      expectation: data.expectation,
    },
  });
}

/**
 * 修改技术咨询
 * @param data
 */
export function updateConsultation(data: ConsultationForm) {
  return request({
    url: "/api/sys/consultation/update/",
    method: "put",
    data: {
      id: data.id,
      demand: data.demand,
      project_brief: data.project_brief,
      question: data.question,
      expectation: data.expectation,
    },
  });
}

/**
 * 删除技术咨询
 *
 * @param id
 */
export function deleteConsultation(id: string) {
  return request({
    url: "/api/sys/consultation/delete?id=" + id,
    method: "delete",
  });
}
//导师解答 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————
/**
 * 获取导师解答分页数据
 *
 * @param queryParams
 */
export function getSolutionPage(
  queryParams?: ConsultationQuery
): AxiosPromise<ConsultationPageResult> {
  return request({
    url: "/api/sys/consultation/select",
    method: "get",
    params: queryParams,
  });
}
/**
 * 获取导师解答详情
 *
 * @param id
 */
export function getSolutionForm(id: string): AxiosPromise<ConsultationForm> {
  return request({
    url: "/api/sys/consultation/solution/selectSolution{id}?id=" + id,
    method: "get",
  });
}

/**
 * 删除导师解答
 *
 * @param id
 */
export function deleteSolution(id: string) {
  return request({
    url: "/api/sys/consultation/solution/delete",
    method: "delete",
    data: {
      id: id,
    },
  });
}
